package org.docshare.zhuishu;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import android.R.integer;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

/**
 * Created by Administrator on 2016/5/14.
 */
public class LeftMenuFragment extends Fragment {


    ListView menu;

    private static final String TAG = "LeftMenuFragment";

    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View inf = inflater.inflate(R.layout.left_menu,null);
        //ButterKnife.bind(this.getActivity());
        menu = (ListView)inf.findViewById(R.id.leftm);
        Log.i(TAG, "onCreateView---------------: "+ (menu == null));

        String[] from = {"img","bigt"};
        int[] to = {R.id.img,R.id.bigt};
        Object o = buildData();
        SimpleAdapter adapter = new SimpleAdapter(this.getContext(), (List<? extends Map<String, ?>>)o, R.layout.item_menu,from,to);
        menu.setAdapter(adapter);
        

        if(GlobalConfig.main_menu_listener != null){
            menu.setOnItemClickListener(GlobalConfig.main_menu_listener);
        }
        return inf;
    }
    
    private List<Map<String, Object>> buildData(){
    	List<Map<String, Object>> list = new ArrayList<Map<String,Object>>();

    	int[] imgs = {R.drawable.ic_action_storage,R.drawable.ic_action_search,R.drawable.ic_action_person};
    	
        String[] sa = {"书架","发现","个人"};
    	for(int i=0;i<sa.length;i++){
    		Map<String,Object> map = new HashMap<String, Object>();
    		map.put("img", imgs[i]);
    		map.put("bigt", sa[i]);
    		list.add(map);
    	}
    	return list;
    	
    	
    }

}
